import { request } from "@utils/http";
import { DeparmentItems, HospitalScheduleDoctorItems, ProvinceItems, ReqGetHospitalListParams, ReqGetHospitalListResponse, ReqGetHospitalScheduleDoctorParams, ReqGetHospitalScheduleRuleParams, ReqGetHospitalScheduleRuleResponse, ReqGetHospitalShowResponse } from "./model/hospitalListTypes";

/**
 * 获取省份信息
 * @returns  Promise<ProvinceItems>
 */ 
export function ReqGetProvince(){
    return request.get<any,ProvinceItems>('/admin/cmn/dict/findByDictCode/province')
} 

/**
 * 获取市和区县的信息
 * @param parentId 父级地区的id
 * @returns Promise<ProvinceItems>
 */
export function ReqGetCityOrDistRict(parentId:number){
    return request.get<any,ProvinceItems>(`/admin/cmn/dict/findByParentId/${parentId}`)
}

/**
 * 获取医院的类型
 * @returns Promise<ProvinceItems>
 */
export function ReqGetHostype(){
    return request.get<any,ProvinceItems>('/admin/cmn/dict/findByDictCode/hostype')
}

/**
 * 获取医院列表
 * @param  
 * @returns Promise<ReqGetHospitalListResponse>
 */
export function ReqGetHospitalList({page,limit,...args}:ReqGetHospitalListParams){
    return request.get<any,ReqGetHospitalListResponse>(`/admin/hosp/hospital/${page}/${limit}`,{
        params:args
    })
}

/**
 * 获取医院详情
 * @param id 用于获取医院详情的id
 * @returns Promise<ReqGetHospitalShowResponse>
 */
export function ReqGetHospitalShow(id:string){
    return request.get<any,ReqGetHospitalShowResponse>(`/admin/hosp/hospital/show/${id}`);
}

/**
 * 获取科室信息
 * @param hoscode 用于获取科室的医院编号 
 * @returns Promise<DeparmentItems>
 */
export function ReqGetDepartment(hoscode:string){
    return request.get<any,DeparmentItems>(`/admin/hosp/department/${hoscode}`)
}

/**
 * 获取医院排班规则
 * @param param0 page:当前显示页面,limit:每页显示数量,hoscode:医院编号,depcode:科室编号
 * @returns Promise<ReqGetHospitalScheduleRuleResponse>
 */
export function ReqGetHospitalScheduleRule({page,limit,hoscode,depcode}:ReqGetHospitalScheduleRuleParams){
    return request.get<any,ReqGetHospitalScheduleRuleResponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)
}

/**
 * 获取医生排班信息
 * @param param0 hoscode:医院编号 ,depcode:科室编号, workDate:工作时间
 * @returns Promise<HospitalScheduleDoctorItems>
 */
export function ReqGetDoctor({hoscode,depcode,workDate}:ReqGetHospitalScheduleDoctorParams){
    return request.get<any,HospitalScheduleDoctorItems>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)
}

/**
 * 用于更新医院上线下线
 * @param id :医院id
 * @param status :医院状态
 * @returns Promise<null>
 */
export function ReqUpdateStatus(id:string,status:number){
    return request.get<any,null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`)
}